package com.fadadianqi.mall.product.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.mall.product.dao.ItemSPUAttrDAO;
import com.fadadianqi.mall.product.dao.ItemSPUDAO;
import com.fadadianqi.mall.product.model.ItemSPU;
import com.fadadianqi.mall.product.model.ItemSPUAttr;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by aroot on 2/19/14.
 */
@Component
public class ItemSPUAttrDAOImpl extends GenericDAOSuport<String, ItemSPUAttr> implements ItemSPUAttrDAO {
    @Override
    protected Class<?> getObjectClass() {
        return ItemSPUAttr.class;
    }

    @Override
    protected String getTableName() {
        return "mall_item_spu_attr";
    }

    @Override
    public ItemSPUAttr getByIdAndValId(String spuId, String valId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("spuId", spuId);
        map.put("attrValId", valId);
        return super.getByPropertys(map);
    }

    @Override
    public List<ItemSPUAttr> findBySpuId(String spuId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("spuId", spuId);
        return super.findByPropertys(map);
    }

    @Override
    public void removeBySpuId(String spuId) {
        super.removeByProperty("spuId", spuId);
    }
}
